package com.itheima.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.domain.db.User;
import com.itheima.mapper.UserMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
@DubboService
public class UserserviceImpl implements UserService {
    //注入mapper接口，调用spl
    @Autowired
    private UserMapper userMapper;
    //添加用户
    @Override
    public Long sava(User user) {
        userMapper.insert(user);
        return user.getId();
    }
    //通过手机号查询用户
    @Override
    public User findByPhone(String phone) {
        QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
        userQueryWrapper.eq("phone",phone);
        User user = userMapper.selectOne(userQueryWrapper);
        return user ;
    }
}
